<!--{template common/header}-->
<!--{if $op == 'delete'}-->
	<h3 class="flb">
		<em>放入回收站</em>
		<!--{if core::gpc('ajax', 'R')}--><span><a href="javascript:;" onclick="hideWindow('$_G[gp_handlekey]');" class="flbc" title="关闭">关闭</a></span><!--{/if}-->
	</h3>
	<form method="post" id="articleform" autocomplete="off" action="{CMS_URL}index.php?group=user&option=article&task=delete&aid=$_GET[aid]">
		<div class="c">
			<!--{if $_G['group']['allowarticlemod'] && $article['status'] == 1}-->
			请确认您需要删除这篇文章？
			<input type="hidden" name="optype" value="0" class="pc" />
			<!--{else}-->
			<label><input type="radio" name="optype" value="0" class="pc" /> 直接删除</label>&nbsp;&nbsp;&nbsp;
			<label><input type="radio" name="optype" value="1" class="pc" checked="checked" /> 放入回收站</label>
			<!--{/if}-->
		</div>
		<p class="text-center">
			<button type="submit" name="btnsubmit" value="true" class="btn"><strong>确认</strong></button>
		</p>
		<input type="hidden" name="aid" value="$_GET[aid]" />
		<input type="hidden" name="referer" value="$_G[referer]" />
		<input type="hidden" name="deletesubmit" value="true" />
		<input type="hidden" name="formhash" value="{FORMHASH}" />
	</form>
<!--{elseif $op == 'related'}-->
	<!--{if $ra}-->
	<li id="raid_li_$ra[aid]"><input type="hidden" name="raids[]" value="$ra[aid]" size="5">[ $ra[aid] ] <a href="index.php?task=view&aid=$ra[aid]" target="_blank">$ra[title]</a> <a href="javascript:;" onclick="raid_delete($ra[aid]);">删除</a></li>
	<!--{/if}-->

<!--{else}-->
<!-- main START -->
<section class="container">

<div class="content-wrap">
	<div class="content">
		<header class="article-header">
			<h1 class="article-title"><!--{if !empty($aid)}-->编辑<!--{else}-->发布<!--{/if}-->文章</h1>
		</header>

		<article>

			<form method="post" autocomplete="off" id="articleform" action="{CMS_URL}index.php?group=user&option=article{if $_G[gp_modarticlekey]}&modarticlekey=$_G[gp_modarticlekey]{/if}" enctype="multipart/form-data">
				<div>
					<dl>
						<dt>标题</dt>
						<dd>
							<input type="text" id="title" name="title" value="$article[title]" style="width:590px;" />
						</dd>
					</dl>
					<dl>
						<dt>别名</dt>
						<dd>
							<input type="text" id="shorttitle" name="shorttitle" value="$article[shorttitle]" style="width:590px;" />
						</dd>
					</dl>
					<!--{if empty($article['aid']) || empty($article['catid'])}-->
					<dl>
						<dt>分类</dt>
						<dd>
							<span class="ftid">
								<select name="catid" id="catid" class="ps">
									<option value="0">请选择分类</option>
									<!--{loop $allcategory $cat}-->
									<option value="{$cat[catid]}" <!--{if $catid==$cat[catid]}-->selected<!--{/if}-->>$cat[pre] $cat[catname]</option>
									<!--{/loop}-->
								</select>
							</span>
							<script type="text/javascript">simulateSelect('catid', 216);</script>
						</dd>
					</dl>
					<!--{/if}-->
					<dl>
						<dt>作者</dt>
						<dd>
								<input type="text" name="author" value="$article[author]" size="10" />
						</dd>
					</dl>
					<dl>
						<dt>来源</dt>
						<dd>
								<input type="text" name="from" value="$article[from]" size="10" />
						</dd>
					</dl>
					<dl>
						<dt>来源网址</dt>
						<dd>
								<input type="url" name="fromurl" value="$article[fromurl]" size="30" />
						</dd>
					</dl>
					<input type="hidden" id="conver" name="conver" value="" />
				<!--{if $article['aid']}-->
					<div><dl class="clearfix">
					<dt>保存到</dt>
					<dd>{$pageselect}
					<a href="index.php?group=user&option=article&task=addpage&aid=$aid" class="btn">添加一个新页面</a>
					<!--{if $article_content}-->
						<a href="index.php?group=user&option=article&task=delpage&aid=$aid&cid=$article_content[cid]" class="btn">删除当前页</a>
					<!--{else}-->
						<a href="javascript:history.back();" class="btn">删除当前页</a>
					<!--{/if}-->
					</dd>
					</dl>
					$multi
					</div>
				<!--{/if}-->
				<style>
				.xhe_vista table{
				border-collapse: separate;
				}
				</style>
				<script language="javascript" src="{CMS_URL}static/js/xheditor-1.2.1/xheditor-1.2.1.min.js"></script>
				<script language="javascript" src="{CMS_URL}static/js/xheditor-1.2.1/xheditor_lang/zh-cn.js"></script>
				<script language="javascript" src="{CMS_URL}static/js/xheditor-1.2.1/editor_function.js"></script>
				<textarea id="jycms-ttHtmlEditor" name="content" style="width: 860px; height: 500px;">$article_content[content]</textarea>
					<dl>
						<dt>标签</dt>
						<dd>
							<input type="text" id="tagname" name="tagname" value="$article[tagname]" style="width:590px;" />
						</dd>
					</dl>

				<dl>
					<img style="float:right; display:none; margin-top: 8px;" id="st_ajax_loading" src="{CMS_URL}static/images/common/ajax-loader.gif" alt="Ajax loading">
					<dt>推荐标签来源：</dt>
					<dd>
					<a rel="split" class="gettag btn" href="#gettags">智能分词</a>
					<a rel="local" class="gettag btn" href="#gettags">本地标签</a>
					<a rel="discuz" class="gettag btn" href="#gettags">DiscuzX</a>
					</dd>
				</dl>
				<div class="inside" id="gettags">
					<span class="container_clicktags"><span>选择推荐标签来源</span></span>
					<div class="clearfix"></div>
				</div>
				<div>摘要</div>
				<textarea name="summary" cols="80" class="pt" style="width: 860px;">$article[summary]</textarea>
				<!--{if $page<2 && $op != 'addpage'}-->
				{if $customfields}
				<div class="text-left">自定义字段</div>
				<select id="customfieldid" name="customfieldid" onchange="showdivcustomfieldtext()">
					<option value="0" {if $article[customfieldid]==0}selected{/if}>不使用</option>
					{loop $customfields $v}
					<option value="{$v[customfieldid]}" {if $article[customfieldid]==$v[customfieldid]}selected{/if}>$v[name]</option>
					{/loop}
				</select>
				{$cfhtml}
				{/if}
				<div>相关文章 <a id="related_article" href="index.php?group=user&option=related&catid=$catid&aid=$aid" style="text-decoration: underline;" onclick="showWindow(this.id, this.href, 'get', 0)">选择</a></div>
				<ul id="raid_div" class="xl">
						<!--{if $article[related]}-->
						<!--{loop $article[related] $ra}-->
						<li id="raid_li_$ra[aid]"><input type="hidden" name="raids[]" value="$ra[aid]" size="5"><a href="index.php?task=view&aid=$ra[aid]" target="_blank">$ra[title]</a> (文章 ID: $ra[aid]) <a href="javascript:;" onclick="raid_delete($ra[aid]);" class="xg1">删除</a></li>
						<!--{/loop}-->
						<!--{/if}-->
				</ul>
				<!--{/if}-->
				<div>
					<button type="button" id="issuance" class="btn" name="articlebutton" onclick="validatef(this);"><strong>提交</strong></button>
					<label><input type="checkbox" name="addpage" value="1" class="pc"> 保存后添加一个新页面</label>
					<!--{if $cate[allowcomment]}--><label for="ck_allowcomment"><input type="checkbox" name="forbidcomment" id="ck_allowcomment" class="pc" value="1"{if isset($article['allowcomment']) && empty($article['allowcomment'])}checked="checked"{/if} /> 禁止评论此文章</label><!--{/if}-->
				</div>
				<input type="hidden" id="aid" name="aid" value="$article[aid]" />
				<input type="hidden" name="cid" value="$article_content[cid]" />
				<input type="hidden" id="attach_ids" name="attach_ids" value="0" />
				<input type="hidden" name="articlesubmit" value="true" />
				<!--{if $op=='edit'||$op=='addpage'}-->
				<input type="hidden" name="catid" value="$catid" />
				<!--{/if}-->
				<input type="hidden" name="formhash" value="{FORMHASH}" />
				<input type="hidden" name="authcode" value="{$authcode}" />
			</form>
		</article>
	</div>
</div>
<aside class="sidebar">	
	<div class="widget d_textbanner" style="padding: 1px 4px 4px 16px;">
		<p class="style02"><strong>上传附件</strong></p>
		<p>为当前文章上传图片、文件附件资源。<br>上传完毕后，需要插入到文章内容中才可以显示。</p>
		<script src="{CMS_URL}static/js/jquery/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
		<link href="{CMS_URL}static/js/jquery/uploadify/uploadify.css" rel="stylesheet" type="text/css">
		<script type="text/javascript">
		$(function() {
		    $('#uploadify').uploadify({
				'overrideEvents': ['onUploadStart'],
				'method'      : 'POST',
		    	buttonClass   : 'btn',
				fileObjName   : 'attach',
		        height        : 20,
		        width         : 80,
		        swf           : '{CMS_URL}static/js/jquery/uploadify/uploadify.swf',
		        uploader      : '{CMS_URL}index.php?group=user&option=upload&aid={$aid}',
				formData      : {'authcode':'{$authcode}','formhash':'{FORMHASH}'},
		        fileSizeLimit : '100MB',
				queueID       : 'fileQueue',
				auto          : false,
				buttonText    : '浏览',
				CompleteText  : '已完成',
				CancelledText : '已取消',
		        multi         : true,
		        'onUploadSuccess' : function(file, data, response) {
		            //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
					$('#' + file.id).find('.data').html(' - 已完成');
		            eval(data);
		        },
		        'onUploadError' : function(file, errorCode, errorMsg, errorString) {
					if(errorString!='Cancelled')
		            alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
		        },
		        'onUploadStart' : function(file) {
		        	$('#articleform').bind('submit', hasUpload);
		            $('#startUpload').hide();
					$('#cancelUpload').show();
		        },
		        'onQueueComplete' : function(queueData) {
		            $('#startUpload').hide();
					$('#cancelUpload').hide();
		        	$('#articleform').unbind('submit', hasUpload);
		        },
		        'onSelect' : function(file) {
		        	$('#articleform').bind('submit', hasUpload);
		            $('#startUpload').show();
		        },
		        'onCancel' : function(file) {
					if(this.queueData.queueLength==1) {
						$('#startUpload').hide();
		        		$('#articleform').unbind('submit', hasUpload);
					}
		        },
			});
		});
		function hasUpload(){
			return false;
		}
		</script>
		<div id="uploadbox">
			<div id="fileQueue"></div>
			<input type="file" name="uploadify" id="uploadify" />
			<button class="btn" onclick="$('#uploadify').uploadify('upload', '*')" id="startUpload" style="display: none;">上传</button>
			<button class="btn" onclick="$('#uploadify').uploadify('cancel', '*')" id="cancelUpload" style="display: none;">取消</button>
			<p class="textmsg" id="divshowuploadmsg" style="display:block"></p>
		</div>
		<iframe id="uploadframe" name="uploadframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
		<div style="max-height: 620px; overflow: auto;" class="d_postlist">
			<ul id="attach_image_body">
				$article[attach_image]
			</ul>
		</div>
		<div id="attach_file_body">$article[attach_file]</div>

	</div>
</aside>
<script type="text/javascript">
	$(function() {
		$("a.gettag").click(function(event) {
			event.preventDefault();
			var type = $(this).attr('rel');
			$('#st_ajax_loading').show();
			$("#gettags .container_clicktags").load( SITEURL + 'index.php?option=misc&task=gettags&action='+type, {content:getContentFromEditor(),title:$("#title").val()}, function(){
				registerClickTags();
			});
			return false;
		});
		initEditor('jycms-ttHtmlEditor');
		if($('input[id="title"]')) {
			$('input[id="title"]')[0].focus();
		}
	});
	function raid_add() {
		var raid = $('#raid').val();
		if($('#raid_li_'+raid)) {
			alert('指定的文章已经存在');
			return false;
		}
		var url = SITEURL+'index.php?group=user&option=related&ajax=1&aid={$article[aid]}&raid='+raid;
		var x = new Ajax();
		x.get(url, function(s){
			s = trim(s);
			if(s) {
				$('#raid_div').append(s);
			} else {
				alert('没有找到指定的文章');
				return false;
			}
		});
	}
	function raid_delete(aid) {
		if(!aid) return;
		$('#raid_li_'+aid).remove();
	}

	function showdivcustomfieldtext() {
		id = $("#customfieldid").val();
		for(i=1;i<=$tbodynum;i++){
			obj=$("#cf_"+i);
			if(i == id) {
				obj.show();
			} else {
				obj.hide();
			}
		}
	}
	function adddivcustomfield(id, str) {
		var oDiv=document.createElement("div");
		document.getElementById(id).appendChild(oDiv);
		oDiv.innerHTML = str;
	}
</script>
<!--{/if}-->

<!--{template common/footer}-->
